package o;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.a;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.forum.base.card.bean.Section;
import java.util.ArrayList;
import java.util.List;
import o.bun.d;
import o.bun.e;

public class but extends a {
    private final Context ˋ;
    private List<Section> ˏ = new ArrayList();
    private int ॱ;

    public but(Context context) {
        this.ˋ = context;
    }

    @NonNull
    public s ˎ(@NonNull ViewGroup viewGroup, int i) {
        return new bvh(LayoutInflater.from(viewGroup.getContext()).inflate(d.ॱᐝ, viewGroup, false));
    }

    public void ॱ(@NonNull s sVar, int i) {
        if ((sVar instanceof bvh) && this.ˏ != null && this.ˏ.size() > 0) {
            ˏ((bvh) sVar, i, this.ˏ);
        }
    }

    private void ˏ(final bvh o_bvh, int i, List<Section> list) {
        if (list != null && list.size() > 0) {
            int i2 = i * 2;
            final Section section = (Section) list.get(i2);
            if (section != null) {
                eqx.ˏ(o_bvh.ʻॱ, section.ॱ(), "app_default_icon");
                o_bvh.ॱˋ.setText(section.ˏ());
                o_bvh.ᐝॱ.setText(bst.ॱ(this.ˋ, section.ˎ()));
                o_bvh.ʽॱ.setText(bst.ॱ(this.ˋ, (long) section.ʻ()));
                o_bvh.ॱᐝ.setOnClickListener(new evx(this) {
                    final /* synthetic */ but ˊ;

                    public void ˋ(View view) {
                        bvf.ˋ().ˊ(this.ˊ.ˋ, section, o_bvh.ʽॱ);
                    }
                });
            }
            if (i2 + 1 < list.size()) {
                o_bvh.ˊˋ.setVisibility(0);
                o_bvh.ʿ.setVisibility(0);
                section = (Section) list.get(i2 + 1);
                if (section != null) {
                    eqx.ˏ(o_bvh.ʾ, section.ॱ(), "app_default_icon");
                    o_bvh.ʼॱ.setText(section.ˏ());
                    o_bvh.ˈ.setText(bst.ॱ(this.ˋ, section.ˎ()));
                    o_bvh.ˊᐝ.setText(bst.ॱ(this.ˋ, (long) section.ʻ()));
                    o_bvh.ʿ.setOnClickListener(new evx(this) {
                        final /* synthetic */ but ॱ;

                        public void ˋ(View view) {
                            bvf.ˋ().ˊ(this.ॱ.ˋ, section, o_bvh.ˊᐝ);
                        }
                    });
                }
            } else {
                o_bvh.ˊˋ.setVisibility(4);
                o_bvh.ʿ.setVisibility(4);
            }
            o_bvh.ˋˊ.setVisibility(0);
            if (i == ˏ() - 1) {
                o_bvh.ˋˊ.setVisibility(8);
            }
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) o_bvh.ˊˊ.getLayoutParams();
            if (marginLayoutParams != null) {
                ˎ(i, marginLayoutParams);
                o_bvh.ˊˊ.setLayoutParams(marginLayoutParams);
            }
        }
    }

    private void ˎ(int i, MarginLayoutParams marginLayoutParams) {
        if (i == 0) {
            marginLayoutParams.topMargin = -this.ˋ.getResources().getDimensionPixelSize(e.ॱ);
        } else {
            marginLayoutParams.topMargin = 0;
        }
    }

    public void ˋ(List<Section> list) {
        this.ˏ = list;
        ॱ();
        ˊ();
    }

    private void ॱ() {
        if (this.ˏ.size() % 2 != 0) {
            this.ॱ = (this.ˏ.size() / 2) + 1;
        } else {
            this.ॱ = this.ˏ.size() / 2;
        }
    }

    public int ˏ() {
        return this.ॱ;
    }
}
